﻿using System.Data;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.DataAccess.Extensions
{
	/// <summary>
	/// CensusGeometryDTODataContract
	/// </summary>
    public static class CensusGeometryDTODataContract
    {
		/// <summary>
		/// DataContract.
		/// </summary>
		/// <param name="rdr">The RDR.</param>
		/// <returns>Object: <see cref="CensusGeometryDTO"/></returns>
        public static CensusGeometryDTO DataContract(IDataReader rdr)
        {
            var newItem = new CensusGeometryDTO();

            newItem.uogID = (int)rdr["uogid"];
            newItem.doj00 = rdr["doj00"].ToString();
            if (string.Equals(rdr["parentid"].ToString(), ""))
            {
                newItem.parentUogID = -1;
            }
            else
            {
                newItem.parentUogID = (int)rdr["parentid"];
            }
            //if (string.Equals(rdr["firstchildid"].ToString(), ""))
            //{
            //    newItem.firstChildUogID = -1;
            //}
            //else
            //{
            //    newItem.firstChildUogID = (int)rdr["firstchildid"];
            //}
            //if (string.Equals(rdr["lastchildid"].ToString(), ""))
            //{
            //    newItem.lastChildUogID = -1;
            //}
            //else
            //{
            //    newItem.lastChildUogID = (int)rdr["lastchildid"];
            //}
            if (string.Equals(rdr["layerid"].ToString(), ""))
            {
                newItem.layerID = -1;
            }
            else
            {
                newItem.layerID = (int)rdr["layerid"];
            }
            //if (string.Equals(rdr["regionid"].ToString(), ""))
            //{
            //    newItem.regionID = -1;
            //}
            //else
            //{
            //    newItem.regionID = (int)rdr["regionid"];
            //}
            newItem.uogType = (int)rdr["uogtype"];

            return newItem;

        }
    }
}
